package com.wms.controller;

import com.wms.dto.WarehouseAreaLocalDto;
import com.wms.dto.WarehouseAreaLocalPageDto;
import com.wms.dto.WarehouseAreaLocalQueryDto;
import com.wms.pojo.PageResult;
import com.wms.pojo.Result;
import com.wms.pojo.WarehouseAreaLocal;
import com.wms.service.WarehouseAreaLocalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Yzxxn
 */
@RestController
@RequestMapping("/warehousearealocal")
public class WarehouseAreaLocalController {

    @Autowired
    private WarehouseAreaLocalService warehouseAreaLocalService;

    @GetMapping("/page")
    public Result getWarehouseAreaLocalByPage(WarehouseAreaLocalQueryDto dto) {
        PageResult result = warehouseAreaLocalService.getWarehouseAreaLocaByPage(dto);
        return Result.success(result);
    }

    @GetMapping
    public Result queryPage(WarehouseAreaLocalPageDto dto) {
        PageResult pageResult = warehouseAreaLocalService.queryPage(dto);
        return Result.success(pageResult);
    }

    //新增
    @PostMapping
    public Result saveWarehouseAreaLocal(@RequestBody WarehouseAreaLocalDto dto) {
        warehouseAreaLocalService.saveWarehouseAreaLocal(dto);
        return Result.success();
    }

    //回显
    @GetMapping("/{id}")
    public Result getWarehouseAreaLocalById(@PathVariable Integer id) {
        WarehouseAreaLocal warehouseAreaLocal = warehouseAreaLocalService.getById(id);
        return Result.success(warehouseAreaLocal);
    }

    //修改
    @PutMapping
    public Result updateWarehouseAreaLocalById(@RequestBody WarehouseAreaLocalDto dto) {
        warehouseAreaLocalService.updateWarehouseAreaLocalById(dto);
        return Result.success();
    }

    //删除
    @DeleteMapping("/{id}")
    public Result deleteWarehouseAreaLocalById(@PathVariable Integer id) {
        warehouseAreaLocalService.removeById(id);
        return Result.success();
    }

    //查询所有
    @GetMapping("/all")
    public Result getWarehouseLocal() {
        List<WarehouseAreaLocal> list = warehouseAreaLocalService.getlist();
        return Result.success(list);
    }
}
